<%@page import="java.util.TimeZone"%>
<%@page import="Model.Purchase.PurchaseListView"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
   long current=System.currentTimeMillis();
   long zero=(current/(1000*3600*24)*(1000*3600*24)-TimeZone.getDefault().getRawOffset())/1000;
   PurchaseListView pur = new PurchaseListView(pageContext);
   pur.request();
   String shijian = pur.get("shijian");
   int pag = Integer.parseInt(pur.get("page"));
   pag = (pag-1)*10;
   switch (shijian) {
           case "0":
               shijian = "-1";
               break;
           case "1":
               shijian = String.valueOf(zero);
               break;
           case "3":
               shijian = String.valueOf(zero - (86400 * 3));
               break;
           case "7":
               shijian = String.valueOf(zero - (86400 * 7));
               break;
           case "30":
               shijian = String.valueOf(zero - (86400 * 30));
               break;
           case "365":
               shijian = String.valueOf(zero - (86400 * 365));
               break;
       }
   
    if(shijian.equals("0")){
      shijian="-1";
    }
    if(pur.get("gonggao").equals("0")){
//   pur.query("select * from purchase_list_view where typid=1 and state=1 and  shijian>="+shijian+" and  name like'%"+pur.get("materielname")+"%' and shengid like '%"+pur.get("shengid") +"%' and shiid like '%"+pur.get("shiid")+"%' and xianid like '%"+pur.get("xianid")+"%' order by id desc limit "+pag+",10");
pur.query("select * from purchase_list_view where typid=1 and state=1 and  shijian>="+shijian+" and  name like'%"+pur.get("materielname")+"%'  order by id desc limit "+pag+",10");
   out.print(pur.toKeyValue()); 
    }else{
//        pur.query("select * from purchase_list_view where typid=1 and shijian>="+shijian+" and  name like'%"+pur.get("materielname")+"%' and shengid like '%"+pur.get("shengid") +"%' and shiid like '%"+pur.get("shiid")+"%' and xianid like '%"+pur.get("xianid")+"%' and state= 2 or state=3 order by id desc limit "+pag+",10");
 pur.query("select * from purchase_list_view where typid=1 and shijian>="+shijian+" and  name like'%"+pur.get("materielname")+"%' and state= 2 or state=3 order by id desc limit "+pag+",10");
   out.print(pur.toKeyValue());
    }
%>